<{extend name="public/base"}>
<{block name="foot_source"}>
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">
<{/block}>
<{block name="content"}>
<!-- left column -->
<div class="col-md-12">
    <!-- general form elements -->
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title"><{$title}></h3>
        </div>
        <!-- /.box-header -->
        <!-- form start -->
        <form role="form" action="<{:url('admin/company/handle')}>" method="post">
            <div class="box-body">
                <div class="form-group">
                    <label for="mobile">用户账号(手机号)</label>
                    <input type="text" class="form-control" id="mobile" name="mobile" placeholder="输入用户账号">
                </div>
                <div class="form-group">
                    <label for="password">登录密码</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="输入登录密码">
                </div>
                <div class="form-group">
                    <label for="company_name">公司名称</label>
                    <input type="text" class="form-control" id="company_name" name="company_name" placeholder="输入公司名称">
                </div>

                <div class="form-group">
                    <label for="password">类型</label>
                    <select name="type" class="form-control">
                        <option value="2">工厂</option>
                        <option value="3">展览馆</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="password">省</label>
                    <select name="province_id" class="form-control" id="province">
                    </select>
                </div>


                <div class="form-group">
                    <label for="password">市</label>
                    <select name="city_id" class="form-control" id="city"></select>
                </div>


                <div class="form-group">
                    <label for="password">区县</label>
                    <select name="district_id" class="form-control" id="district"></select>
                </div>


            </div>
            <!-- /.box-body -->

            <div class="box-footer">
                <button type="submit" class="btn btn-primary">提交</button>
                <a href="<{:url('admin/admin/index')}>" class="btn btn-warning ">返回列表</a>
            </div>
        </form>
    </div>
    <!-- /.box -->
</div>

<{/block}>
<{block name="foot_script"}>
    <script type="text/javascript">


        $(function(){
            $("#province").change(function(){
                var id = $(this).val();
                getCity(id);
            });


            $("#city").change(function(){
                var id = $(this).val();
                getDistrict(id);
            });

            getProvince();


            function getProvince(){
                $.post('/admin/api/getProvince',function(data){
                    var data = data.data;
                    $("#province").html("");
                    for(var i = 0; i< data.length; i++ ){
                        $("#province").append("<option value='"+data[i]['aid']+"'>"+data[i]['name']+"</option>");
                    }
                    if(data[0]){
                        getCity(data[0]['aid']);
                    }
                });
            }

            function getCity(province_id){
                $.post('/admin/api/getCity/province_id/'+province_id,function(data){
                    var data = data.data;
                    $("#city").html("");
                    for(var i = 0; i< data.length; i++ ){
                        $("#city").append("<option value='"+data[i]['aid']+"'>"+data[i]['name']+"</option>");
                    }
                    if(data[0]){
                        getDistrict(data[0]['aid']);
                    }
                });
            }

            function getDistrict(city_id){
                $.post('/admin/api/getDistrict/city_id/'+city_id,function(data){
                    var data = data.data;
                    $("#district").html("");
                    for( var i = 0; i< data.length; i++ ){
                        $("#district").append("<option value='"+data[i]['aid']+"'>"+data[i]['name']+"</option>");
                    }
                });
            }
        });


    </script>
<{/block}>

